'''
营销首页
'''
from selenium.webdriver.common.by import By
from page.base_page import BasePage

class zhanleixingsouye(BasePage):
    url = 'http://192.168.1.25/crm/index.php?m=message'
    # 点击更多
    dianji_gd_locator = (By.XPATH, '/html/body/div[1]/div/div/div[2]/ul[1]/li[9]/a')
    # 点击站内信
    dianji_zlx_locator = (By.XPATH, '/html/body/div[1]/div/div/div[2]/ul[1]/li[9]/ul/li[4]/a')
    # 点击写信
    dainji_xx_locator = (By.ID, 'send')
    # 勾选
    gouxuan_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    #批量操作
    plcz_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div > div.span12.nav > div > ul > li.nav.pull-left > div > a')
    # 删除
    sc_locator = (By.CSS_SELECTOR, '#delete_receive')
    # 勾选收件人
    gouxuanshoujianren_locator = (By.CSS_SELECTOR, '#ta1 > input')
    # 输入内容
    leirong_shuru_locator = (By.NAME, 'content')
    # 点击发送
    dianjia_faso_locator = (By.CSS_SELECTOR, '#dialog-message-send > form > table > tfoot > tr > td:nth-child(2) > input.btn.btn-primary')
    # 点击取消
    dianji_quxiao_locator = (By.CSS_SELECTOR, '#dialog-message-send > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(2)')

    def dianjigengduo(self):
        self.driver.find_element(*self.dianji_gd_locator).click()

    def dianjizhanleixing(self):
        self.driver.find_element(*self.dianji_zlx_locator).click()

    def dianjixiexiexing(self):
        self.driver.find_element(*self.dainji_xx_locator).click()

    def guxuan(self):
        self.driver.find_element(*self.gouxuan_locator).click()

    def piliangcaozuo(self):
        self.driver.find_element(*self.plcz_locator).click()

    def shauncu(self):
        self.driver.find_element(*self.sc_locator).click()

    def goxuanshoujianren(self):
        self.driver.find_element(*self.gouxuanshoujianren_locator).click()

    def shuruneirong(self,nr):
        self.driver.find_element(*self.leirong_shuru_locator).send_keys(nr)

    def dianjifason(self):
        self.driver.find_element(*self.dianjia_faso_locator).click()

    def dianjiquxiao(self):
        self.driver.find_element(*self.dianji_quxiao_locator).click()

    # 弹框点击确定
    def queding(self):
        self.driver.switch_to.alert.accept()

    # 获取页面url
    def get_url(self):
            url = self.driver.current_url
            return url